<template>
	<view>
		<!-- 顶部导航 -->
		<u-navbar :background="background">
			<view class="ft_16 fw-b">
				预约记录
			</view>
		</u-navbar>
		<view class="content">
			<u-tabs-swiper ref="uTabs" :list="list" :is-scroll="false" bar-height="6" bar-width="250" active-color="#e67920" :current="current" @change="tabsChange" height="90"></u-tabs-swiper>
			<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" :style="{height:scrollHeight + 'px'}">
				<!-- 全部 -->
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
						<view class="con_2">
							<view class="con_2_1" v-for="(item,index) in kxList" :key="index" :style="kxList.length==index+1?'border:none':''">
								<view class="p_bottom_10 display just_space">
									<view class="">
										<text class="c-999">门店：</text>
										{{item.title}}
									</view>
									<view class="" v-if="item.type==0">
										待完成
									</view>
									<view class="c-999" v-else>
										已完成
									</view>
								</view>
								<view class="p_bottom_10">
									<text class="c-999">预约时间：</text>
									{{item.time}}
								</view>
								<view class="display just_space">
									<view>
										<text class="c-999">预约房间：</text>
										<text>{{item.content}}</text>
									</view>
									<view class="ft_12 seeErweima" v-if="item.type==0" @click="seeEWM(item)">
										查看二维码
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<!-- 待完成 -->
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
						<view class="con_2">
							<view class="con_2_1" v-for="(item,index) in kxList" :key="index" :style="kxList.length==index+1?'border:none':''" v-if="item.type==0">
								<view class="p_bottom_10 display just_space">
									<view class="">
										<text class="c-999">门店：</text>
										{{item.title}}
									</view>
									<view class="">
										待完成
									</view>
								</view>
								<view class="p_bottom_10">
									<text class="c-999">预约时间：</text>
									{{item.time}}
								</view>
								<view class="display just_space">
									<view>
										<text class="c-999">预约房间：</text>
										<text>{{item.content}}</text>
									</view>
									<view class="ft_12 seeErweima" @click="seeEWM(item)">
										查看二维码
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<!-- 已完成 -->
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
						<view class="con_2">
							<view class="con_2_1" v-for="(item,index) in kxList" :key="index" :style="kxList.length==index+1?'border:none':''" v-if="item.type==1">
								<view class="p_bottom_10 display just_space">
									<view class="">
										<text class="c-999">门店：</text>
										{{item.title}}
									</view>
									<view class="c-999">
										已完成
									</view>
								</view>
								<view class="p_bottom_10">
									<text class="c-999">预约时间：</text>
									{{item.time}}
								</view>
								<view class="display just_space">
									<view>
										<text class="c-999">预约房间：</text>
										<text>{{item.content}}</text>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				
			</swiper>
			

		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background:{backgroundColor: '#ffffff',}, //导航栏背景
				list:[
					{
					name: '全部'
					}, {
					name: '待完成'
					}, {
					name: '已完成',
					},
				],
				current: 0, // tabs组件的current值，表示当前活动的tab选项
				swiperCurrent: 0, // swiper组件的current值，表示当前那个swiper-item是活动的
				scrollHeight:"", //滚动高度
				
				kxList:[ //预约列表
					{
						title:"门店名称",
						time:"2020.09.29 10:00-12.00",
						content:"1号房",
						type:0,
					},
					{
						title:"门店名称",
						time:"2020.09.29 10:00-12.00",
						content:"1号房",
						type:1,
					},
				],
				
			}
		},
		onLoad() {
			this.getheight() //获取滚动高度
		},
		methods: {
			seeEWM(item){ //查看二维码
				uni.navigateTo({
					url:"seeEWM"
				})
			},
			
			getheight(){ //获取滚动高度
				let windowHeight=uni.getStorageSync('windowHeight')
				let statusBarHeight=uni.getStorageSync('statusBarHeight')
				this.scrollHeight=windowHeight - statusBarHeight - 44
			},
			
			// tabs通知swiper切换
			tabsChange(index) {
				this.swiperCurrent = index;
			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			transition(e) {
				let dx = e.detail.dx;
				// this.$refs.uTabs.setDx(dx);
			},
			// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
			// swiper滑动结束，分别设置tabs和swiper的状态
			animationfinish(e) {
				let current = e.detail.current;
				this.$refs.uTabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			},
			// scroll-view到底部加载更多
			onreachBottom() {
				
			}
			
		}
	}
</script>

<style lang="scss">
page{
	background-color: #fafafa;
}
.content{
	.con_1{
		
	}
	.con_2{
		padding-top: 5px;
		.con_2_1{
			padding: 20px 15px;border-bottom: 1px solid #eeeeee;
			background-color: #FFFFFF;
			.seeErweima{
				padding: 5px 10px;background: linear-gradient(90deg, #F1A421 0%, #E4741F 100%);color: #FFFFFF;border-radius: 30px;
			}
		}
	}
}

</style>
